package com.huiyang.demo.utils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @ProjectName: DeE12349APP
 * @Package: huiyang.supervise.bed.utils
 * @ClassName: JsonBuilder
 * @Description: java类作用描述
 * @Author: yuan
 * @CreateDate: 2020/9/9 3:50 PM
 */
public class JsonBuilder {

    private JSONObject mJSONObject;

    public JsonBuilder() {
        mJSONObject = new JSONObject();
    }



    public JsonBuilder append(String key, int value) throws JSONException {
        mJSONObject.put(key, value);
        return this;
    }

    public JsonBuilder append(String key, JSONArray value) throws JSONException {
        mJSONObject.put(key, value);
        return this;
    }

    public JsonBuilder append(String key, JsonBuilder value) throws JSONException {
        mJSONObject.put(key, value.builder());
        return this;
    }

    public JsonBuilder append(String key, Object value) throws JSONException {
        mJSONObject.put(key, value);
        return this;
    }

    public JsonBuilder append(String key, boolean value) throws JSONException {
        mJSONObject.put(key, value);
        return this;
    }

    public JsonBuilder append(String key, double value) throws JSONException {
        mJSONObject.put(key, value);
        return this;
    }

    public JsonBuilder append(String key, long value) throws JSONException {
        mJSONObject.put(key, value);
        return this;
    }

    public JSONObject builder() {
        return mJSONObject;
    }
}
